home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: URGENT HELP in declaring arrays of strings
- Date: 21 Feb 1996 13:30:21 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4gg2tdINN3c3@keats.ugrad.cs.ubc.ca>
- References: <4gb1a1$l3v@reader2.ix.netcom.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4gb1a1$l3v@reader2.ix.netcom.com>,
- SPD <spdcool@ix.netcom.com> wrote:
- >Hi,
- >names. That is why I need to know how to assign an array of strings in
- >my assignment. IF I'm wrong in what I think I have to to, please
- >correct me. Thanks alot in advance.
-
- Hand this in (diligently extending it to 15 names first): It assigns the
- strings in array N to array M by copying the pointers.
-
- #define X "Amy","Joe","Bob","Suzy","Mike","Sean","Cathy","Matt",0
- int main(int argc,char**argv){char*N[]={X};char*M[sizeof(N)/sizeof(*N)];
- char**p=N;int i=0;for(;*p;p++,i++)i[M]=*p;return 0;}
-
- Either that, or tell them that arrays can't be assigned in C. They can undergo
- aggregate initialization, which is not assignment.
-
- >please e-mail me at spdcool@ix.netcom.com and spd7398@acf4.nyu.edu
- >mail it to both address b/c I could either be in school or at home.
-
- How about I just FedEx it to you so you get brownie points for early hand-in?
- --
-
-